angular.module('bank-account-edit', [])

.controller 'BankAccountEdit', ($scope, $state, $http, $ionicHistory, $stateParams,userData,showToast) ->
    _.extend $scope,
        account:{
            bankid:0
        }
        goBack:->
            $ionicHistory.goBack()
        save:->
            requestData={
                action:'saveshopbank'
                userid:userData.getToken()
                bankid:$scope.account.bankid
                bankuser:$scope.account.bankuser
                bankname:$scope.account.bankname
                bankcard:$scope.account.bankcard
            }
            $http.post('/utf-8data/',requestData)
            .success (resp) ->
                if resp?.status == '0'
                    showToast '保存成功'
                    $ionicHistory.goBack()
                else
                    showToast '保存失败'
            .error (err) ->
                console.log err
                showToast '网络异常,保存失败'
    $scope.account=$stateParams.account if $stateParams.account?.bankid!=undefined
